<template>
    <el-container>
        <el-container class="is-vertical">
            <div class="panel-search-box">
                <div class="panel-search">
                    <el-date-picker v-model="search.reviewDate" type="date" value-format="YYYY-MM-DD" format="YYYY-MM-DD" placeholder="选择抗遗忘日期" class="sDateSelect" style="margin-left:10px;"
						>
                    </el-date-picker>
                    <el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
                </div>
            </div>
            <el-main class="nopadding" style="min-height:500px;">
                <scDialogTable ref="table" :apiObj="$API.reviewCycle.list" :params="search" remoteSort @dataChange="dataChange" :height="500">
                    <el-table-column label="序号" prop="index" width="70" align="left"></el-table-column>
                    <el-table-column label="学员" prop="user" align="center" >
                        <template #default="scope">
                            {{scope.row.user ? scope.row.user.name : ''}}
                        </template>
                    </el-table-column>
                    <el-table-column label="抗遗忘教练" prop="teacher" width="150" align="center">
                        <template #default="scope">
                            {{scope.row.teacher ? scope.row.teacher.name : ''}}
                        </template>
                    </el-table-column>
                    <el-table-column label="抗遗忘时间" prop="startTime" width="180" align="center"></el-table-column>
                    <el-table-column label="创建时间" prop="createdAt" width="150" align="center"></el-table-column>
                    <el-table-column label="操作" fixed="right" align="center" width="150">
                        <template #default="scope">
                            <el-button type="text" size="small" @click="printFun(scope.row)">打印</el-button>
                        </template>
                    </el-table-column>
                </scDialogTable>
            </el-main>
        </el-container>
    </el-container>


</template>

<script>

export default {
    components: {
    },
    props: {
		learn: { type: Object, default: () => {} },
	},
    data() {
        return {
            dialog: {
                detail: false,
            },
            search: {
                name: null,
                learnId: null,
            }
        }
    },
    created() {
        if (this.learn) {
            this.search.learnId = this.learn.id
        }
    },
    mounted() {
        
    },
    methods: {
        dataChange(res, tableData) {
			let total = res.data.total
            let perPage = res.data.perPage
            let page = (this.$refs.table && this.$refs.table.currentPage) || 1
            tableData.forEach((item, index) => {
				item.index = page * perPage + index - perPage + 1
            })
        },
        //查看
        table_show(row) {
            this.dialog.detail = true
			this.$nextTick(() => {
				this.$refs.detailDialog.open(row.id)
			})
        },
        // 搜索
        upsearch() {
            this.$refs.table.upData(this.search)
        },
        //本地更新数据
        handleSuccess() {
            this.$refs.table.refresh()
        },
        printFun(row) {
            let url =  row.printBaseUrl + '/cycle?id=' + row.id
            window.open(url)
        }
    }
}
</script>

<style>
.position {
    display: flex;
    align-items: center;
}
.position-item {
    margin-right: 5px;
}
.position-item:last-child {
    margin-right: 0;
}
</style>
